﻿using Common.FrontEnd;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FrontEnd.EndPoint
{
    /// <summary>
    /// A container for DoubleData class that indicates whether the contained DoubleData is speech or not. 
    /// </summary>
    public class SpeechClassifiedData:IData
    {
        private Boolean _isSpeech;
        private DoubleData data;


        /**
        /// Constructs a SpeechClassifiedData object.
         *
        /// @param doubleData the DoubleData
        /// @param isSpeech   indicates whether the DoubleData is speech
         */
        public SpeechClassifiedData(DoubleData doubleData, Boolean isSpeech) 
        {
            this.data = doubleData;
            this._isSpeech = isSpeech;
        }


        /**
        /// Sets whether this SpeechClassifiedData is speech or not.
         *
        /// @param isSpeech true if this is speech, false otherwise
         */
        public void setSpeech(Boolean isSpeech) 
        {
            this._isSpeech = isSpeech;
        }


        /**
        /// Returns whether this is classified as speech.
         *
        /// @return true if this is classified as speech, false otherwise
         */
        public Boolean isSpeech() 
        {
            return _isSpeech;
        }


        /**
        /// Returns the data values.
         *
        /// @return the data values
         */
        public double[] getValues() 
        {
            return data.Values;
        }


        /**
        /// Returns the sample rate of the data.
         *
        /// @return the sample rate of the data
         */
        public int getSampleRate() {
            return data.getSampleRate();
        }


        /**
        /// Returns the time in milliseconds at which the audio data is collected.
         *
        /// @return the difference, in milliseconds, between the time the audio data is collected and midnight, January 1,
        ///         1970
         */
        public long getCollectTime() {
            return data.getCollectTime();
        }


        /**
        /// Returns the position of the first sample in the original data. The very first sample number is zero.
         *
        /// @return the position of the first sample in the original data
         */
        public long getFirstSampleNumber() {
            return data.getFirstSampleNumber();
        }


        /**
        /// Returns the DoubleData contained by this SpeechClassifiedData.
         *
        /// @return the DoubleData contained by this SpeechClassifiedData
         */
        public DoubleData getDoubleData() {
            return data;
        }
    

        /**
        /// @return a string that describes the data.
         */
        override
        public String ToString() {
            return "SpeechClassifiedData containing " + data.ToString() + " classified as " + (_isSpeech ? "speech" : "non-speech");
        }


        void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            throw new NotImplementedException();
        }
    }
}
